package com.sayice.gomoku.dao.impl;

import com.sayice.gomoku.dao.BuyDao;

/**
 * 购买记录数据库操作
 */
public class BuyDaoImpl extends BaseDao implements BuyDao {
    @Override
    public int add(int userId, int boardId) {
        String sql = "insert into buy(userId, boardId) values(?, ?)";
        return update(null, sql, userId, boardId);
    }
    
    @Override
    public boolean exists(int userId, int boardId) {
        String sql = "select exists(select * from buy where userId = ? and boardId = ?)";
        return (long) queryForSingleValue(sql, userId, boardId) == 1;
    }
}
